import QtQuick 1.1

Rectangle {
    width: 380
    height: 350
    id: rectangle1
    color: "#206088"

    property int margin: 15
    property string feedType: "inbox"
    LeftTitle{
        id: titleInbox
        x: 16
        y: 15
        width: 61
        height: 21
        underline: true
        size: 20
        text: "inbox"
        anchors.topMargin: 15
        anchors.left: parent.left
        anchors.leftMargin: 16
        anchors.top: parent.top
        MouseArea {
            x: 17
            y: 0
            anchors.rightMargin: -17
            anchors.bottomMargin: 0
            anchors.leftMargin: 17
            anchors.topMargin: 0
             anchors.fill: parent
             onClicked: {
                 feedType = "inbox"
                 parent.underline = true
                 titleSend.underline = false
                 titleTrash.underline = false

             }

        }
    }
    LeftTitle{
        id: titleSend
        x: 165
        y: 15
        width: 50
        height: 21

        size: 20
        text: "send"
        anchors.topMargin: 15
        anchors.top: parent.top
        MouseArea {
            x: 0
            y: 0
            width: 50
            height: 21
            anchors.rightMargin: 0
            anchors.bottomMargin: 0
            anchors.leftMargin: 0
            anchors.topMargin: 0
             anchors.fill: parent
             onClicked: {
                    feedType = "send"
                 parent.underline = true
                 titleInbox.underline = false
                 titleTrash.underline = false

             }

        }
    }
    LeftTitle{
        id: titleTrash
        x: 304
        y: 15
        width: 60
        height: 21

        size: 20
        text: "trash"
        anchors.topMargin: 15
        anchors.top: parent.top

        MouseArea {
            x: -6
            y: 0
            width: 60
            height: 21
            anchors.rightMargin: 6
            anchors.bottomMargin: 0
            anchors.leftMargin: -6
            anchors.topMargin: 0
             anchors.fill: parent
             onClicked: {
                 feedType = "trash"
                 parent.underline = true
                 titleInbox.underline = false
                 titleSend.underline = false

             }

        }
    }



    XmlListModel {
        id: xmlFeeds
        source: "Assets/email/"+feedType+".xml"
        query: "/email/message"
        XmlRole { name: "read"; query: "read/string()" }
        XmlRole { name: "from"; query: "from/string()" }
        XmlRole { name: "to"; query: "to/string()" }
        XmlRole { name: "date"; query: "date/string()" }
        XmlRole { name: "time"; query: "time/string()" }
         XmlRole { name: "name"; query: "name/string()" }
         XmlRole { name: "subject"; query: "subject/string()" }
        XmlRole { name: "msg"; query: "msg/string()" }
    }



Component {
    id: xmlFeedsDelegate
    Rectangle {
        width:380
        height: 70
        color: "#206088"

        Image {
            id: image1
            x: 0
            y: 0
            width: 70
            height: 70
            source: author_image
        }

        Text {
            id: textAuthor
            x: 74
            y: 2
            text: author
            font.family: "Georgia"
            font.bold: true
            font.pixelSize: 11
        }
        Text {
            id: dtext
            x: 74
            y: 16
            anchors.top: textAuthor.bottom
            anchors.topMargin: 0
            width: 324
            height: 42
            color: "#ffffff"


            text: textS
            wrapMode: Text.WordWrap
            font.family: "Georgia"
            font.bold: false
            font.pixelSize: 10

            Text {
                id: text1
                x: 0
                y: 41
                color: "#aa9b9b"
                text: time
                font.pixelSize: 10
            }
        }

        Image {
            id: imgType
            x: 52
            y: 52
            width: 18
            height: 18
            source: "Assets/news/"+type+".png"
        }
    }
}

Item {
    id: rectangle2
    x: 16
    y: 59
    width: 348
    height: 291


    ListView {
        x: 0
        y: -12
        width: 349
        height: 285
        contentHeight: 400
        contentWidth: 400


        clip: true
                       boundsBehavior: Flickable.StopAtBounds
        spacing: 1
        model: xmlFeeds
        delegate: EmailDelegate{}

    }
}
}


//Michal
